﻿using System.Windows.Forms;

namespace Borg.Framework
{
    internal class PlugFormatter
    {
        private object GetLabel(PlugInfo plug)
        {
            var extensionInfo = plug.ExtensionInfo;

            if (extensionInfo.Object is IObjectInfo)
            {
                var objectInfo = (IObjectInfo)extensionInfo.Object;
                return objectInfo.Name;
            }

            return extensionInfo;
        }

        public void OnFormat(object sender, ListControlConvertEventArgs args)
        {
            args.Value = GetLabel((PlugInfo)args.ListItem);
        }
    }
}

